<?php
	include_once 'isLogin.php';

    /*****验证admin用户名唯一性******/
    if($_GET['action']=='checkAdminName'){ //账户名
		$data=trim($_POST['name']);
		if($data!='' && $data!=null){
			$user=$commonc->getInfo("admin",$data,"*","name");
			if($user==false){
				$error=0;
				$msg=" ";
			}else{
				$error=1;
				$msg="账户名已存在";
			}
		}else{
			$error=1;//为空
			$msg="账户名不能为空";
		}
		echo json_encode(array('error'=>$error,'msg'=>$msg));
	 	exit;
	}


	//获得市、区
	if($_GET['action']=='getArea'){
		$child = $commonc->getArea($_POST['type'],$_POST['fatherid']);
		$select = '<option value="">请选择</option>';
		if(is_array($child)){
			$error="0";
			foreach($child as $k=>$v){
				$select.='<option value="'.$v[$_POST['type'].'id'].'">'.$v[$_POST['type']].'</option>';
			}
		}else{
			$error="1";
		}
		if($_POST['fatherid']=="") $error='2';

		$result = array('error'=>$error,'child'=>$select);
		echo json_encode($result);
		exit();
	}


	//读取子时服务的二级目录
	if($_GET['action']=='getClass'){
		$id=$_POST['id'];
		$servicec=new service();
		$select='<option value="">请选择</option>';
		if($id!=''){
			$where=" AND c.upid=".$id; 
			$service_class=$servicec->service_class_list($where);
			$service_class=$service_class['result'];

			if(is_array($service_class)){
				foreach($service_class as $k=>$v){
					$select.='<option value="'.$v['id'].'">';
					$select.=$v['class_name'];
					$select.='</option>';	
				}
			}
		}
		echo $select;
		exit();
	}

	//得到广告位大小
	if($_GET['action']=='getSize'){
		$table_adv_position="adv_position"	; //广告位
		
		$id=$_POST['id'];
		$res=$commonc->getInfo($table_adv_position,$id);
		if($res){
			$error=0;
			$width=$res['width'];
			$height=$res['height'];
		}else{
			$error=1;
		}
		echo json_encode(array('error'=>$error,'width'=>$width,'height'=>$height));
		exit;
	}	





	//获得洲下的国家
	if($_GET['action']=='getCountry'){
		$continent_id=$_POST['continent_id'];
		$table='country';
		$sql=$table.' where father_id="'.$continent_id.'"';
		$countrys=$commonc->getList($sql);
		$html='<option value="">请选择国家</option>';
		if(is_array($countrys['result'])){
			$error=1;
			foreach($countrys['result'] as $k=>$v){
				$html.='<option value="'.$v['id'].'">'.$v['country'].'</option>';
			}
		}
		$result=array('error'=>$error,'html'=>$html);
		echo json_encode($result);
		exit();
	}
 
?>